class Solution {//leetcode712——两个字符串的最小ASCII码删除和
public:
    int minimumDeleteSum(string s1, string s2) {
        int m=s1.size(),n=s2.size();
        s1=" "+s1;
        s2=" "+s2;
        int sum=0;
        for(int i=1;i<m+1;i++) sum+=s1[i];
        for(int j=1;j<n+1;j++) sum+=s2[j];
        vector<vector<int>> dp(m+1,vector<int>(n+1));
        for(int i=1;i<m+1;i++){
            for(int j=1;j<n+1;j++){
                if(s1[i]==s2[j]){
                    dp[i][j]=dp[i-1][j-1]+s1[i]+s2[j];
                }
                else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
        return sum-dp[m][n];
    }
};